// 添加接口
async function addStudent(body) {
    await axios.post('/students', body)
        .then(res => {
            pxmu.success('添加成功')
            setTimeout(() => {
                location.href = './student.html'
            }, 1000);

        })
}

document.querySelector('button').addEventListener('click', function (e) {
    e.preventDefault()// 阻止默认行为
    const form = document.querySelector('#studentForm');
    let data = serialize(form, { hash: true, empty: true })

    // 创建一个新的 Date 对象，表示当前时间
    const now = new Date();

    // 使用 toISOString() 方法获取 ISO 8601 格式的字符串
    const updateAt = now.toISOString();
    //    console.log(updateAt);
    //    data.updateAt = updateAt
    data.age = parseInt(data.age)
    data.gender = parseInt(data.gender)
    data.hope_salary = parseInt(data.hope_salary)
    data.salary = parseInt(data.salary)
    data.group = parseInt(data.group)
    console.log(data);
    addStudent(data)


})
/* 

{
    "name": "黑马程序员1",
    "age": 16,
    "gender": 0,
    "province": "北京",
    "city": "北京",
    "area": "顺义区",
    "hope_salary": 10000,
    "salary": 9000,
    "group": 1
}
*/